package Global;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

import Global.ConstantVariable.DefaultDirectoryNamesConstants;
import Utility.WorkerUtilityClass;

public class DirectoryStructureAndSettingsClass {
   static String rootDirectoryNameForTheCurrentDataset;
   static String fullPathOfTheRootDirectoryNameForTheCurrentDataset;
   
   static String staticRootDirectoryNameForTheCurrentDataset;
   static String fullPathOfTheStaticRootDirectoryNameForTheCurrentDataset;

	//These two variables will be used for interchange of filenames.
	static ArrayList<String> contentsFileNameForSyntheticDatasets;
	static ArrayList<String> linksFileNamesForSyntheticDatasets;
	
	static String datasetName;
	static int synDatasetIndex;
	
	
	static BufferedWriter outForLogFile;
		
	public static String getDatasetName()
	{
		return datasetName;
	}
	
	public static void setDatasetName(String datasetNameToBeSet)
	{
		datasetName = datasetNameToBeSet;		
	}

	public static void setRootDirectoryNameForTheCurrentDataset(String directoryName){
		rootDirectoryNameForTheCurrentDataset=directoryName;
		setFullPathOfTheRootDirectoryNameForTheCurrentDataset(directoryName);
	}
	
	public static void setStaticRootDirectoryNameForTheCurrentDataset(String directoryName){
		staticRootDirectoryNameForTheCurrentDataset=directoryName;
		setFullPathOfTheStaticRootDirectoryNameForTheCurrentDataset(directoryName);
	}
	
	static void setFullPathOfTheRootDirectoryNameForTheCurrentDataset(String directoryName){
		
		String path;
		
		if(GlobalClass.RunningValues.executionFor==ConstantVariable.DataSet_Constants.SYNTETIC_DATASET)
		{
			path = ConstantVariable.DefaultDirectoryNamesConstants.ROOT_DIRECTORY
			  +ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderRootDirectory.DATASETS_MAIN_DIRECTORY
			  +ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetsDirectory.SYNTHETIC_DATA_ROOT_FOLDER_NAME;			  
		}
		else
		{
			path = ConstantVariable.DefaultDirectoryNamesConstants.ROOT_DIRECTORY
			+ ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderRootDirectory.DATASETS_MAIN_DIRECTORY;					
		}
		
		fullPathOfTheRootDirectoryNameForTheCurrentDataset = path + directoryName;		
	}
	
	static void setFullPathOfTheStaticRootDirectoryNameForTheCurrentDataset(String directoryName){
		
		String path;
		
		if(GlobalClass.RunningValues.executionFor==ConstantVariable.DataSet_Constants.SYNTETIC_DATASET)
		{
			path = ConstantVariable.DefaultDirectoryNamesConstants.ROOT_STATIC_DIRECTORY
			  +ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderStaticRootDirectory.DATASETS_MAIN_DIRECTORY
			  +ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetsDirectory.SYNTHETIC_DATA_ROOT_FOLDER_NAME;			  
		}
		else
		{
			path = ConstantVariable.DefaultDirectoryNamesConstants.ROOT_STATIC_DIRECTORY
			+ ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderStaticRootDirectory.DATASETS_MAIN_DIRECTORY;					
		}
		
		fullPathOfTheStaticRootDirectoryNameForTheCurrentDataset = path + directoryName;		
	}
	
	public static String getFullPathOfTheRootDirectoryNameForTheCurrentDataset()
	{	
		return fullPathOfTheRootDirectoryNameForTheCurrentDataset;		
	}
	
	public static String getFullPathOfTheStaticRootDirectoryNameForTheCurrentDataset()
	{	
		System.out.println("fullPathOfTheStaticRootDirectoryNameForTheCurrentDataset:"+fullPathOfTheStaticRootDirectoryNameForTheCurrentDataset);
		return fullPathOfTheStaticRootDirectoryNameForTheCurrentDataset;		
	}
	
	public static String getRootDirectoryNameForTheCurrentDataset(){
		return rootDirectoryNameForTheCurrentDataset;
	}
	
	public static String getcontentFileName(int contentType){
		
		return DirectoryStructureAndSettingsClass.contentsFileNameForSyntheticDatasets.get(contentType);
	}
		
	public static void setcontentFileName(int contentType, String contentFileName){
		if(DirectoryStructureAndSettingsClass.contentsFileNameForSyntheticDatasets==null)
			DirectoryStructureAndSettingsClass.contentsFileNameForSyntheticDatasets =new ArrayList<String>();
		/*	
		if(Parametres.contentsFileNameForSyntheticDatasets.get(contentType)!=null)
		{
			Parametres.contentsFileNameForSyntheticDatasets.set(contentType, contentFileName);			
		}
		else*/
		DirectoryStructureAndSettingsClass.contentsFileNameForSyntheticDatasets.add(contentType, contentFileName);		
	}
	
	public static String getLinksFileName(int linkType) {
		//System.out.println("linkType:"+linkType);
		return DirectoryStructureAndSettingsClass.linksFileNamesForSyntheticDatasets.get(linkType);
	}
	
	public static void setLinkFileName(int linkType, String linkFileName) {
		
		if(DirectoryStructureAndSettingsClass.linksFileNamesForSyntheticDatasets==null)
			DirectoryStructureAndSettingsClass.linksFileNamesForSyntheticDatasets =new ArrayList<String>();
		
		/*if(Parametres.linksFileNamesForSyntheticDatasets.get(linkType)!=null)
		{
			Parametres.linksFileNamesForSyntheticDatasets.set(linkType, linkFileName);			
		}
		else*/
		DirectoryStructureAndSettingsClass.linksFileNamesForSyntheticDatasets.add(linkType, linkFileName);		
	}	
	
	public static void createDirectory(String directoryName) {
		
		try	{
			(new File(directoryName)).mkdir();
	
		}
		catch(Exception e) {
			e.printStackTrace();			
		}
	}
	
	public static void createInitialDirectories() 
	{
		String staticRootName=ConstantVariable.DefaultDirectoryNamesConstants.ROOT_STATIC_DIRECTORY;
		String rootName=ConstantVariable.DefaultDirectoryNamesConstants.ROOT_DIRECTORY;		
		
		createDirectory(staticRootName);
		createDirectory(rootName);		
		
		createDirectory(staticRootName+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderStaticRootDirectory.INPUTS_DIRECTORY);
		
		createDirectory(rootName+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderRootDirectory.DATASETS_MAIN_DIRECTORY);
		createDirectory(rootName+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderRootDirectory.LATEST_RESULTS_DIRECTORY);
		createDirectory(rootName+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderRootDirectory.LOG_DIRECTORY);
		
		createDirectory(staticRootName+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderStaticRootDirectory.DATASETS_MAIN_DIRECTORY);
		
		
		String datasetsMainDir = ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderRootDirectory.DATASETS_MAIN_DIRECTORY;
		datasetsMainDir = rootName + datasetsMainDir; 
		createDirectory(datasetsMainDir +ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetsDirectory.SYNTHETIC_DATA_ROOT_FOLDER_NAME);
		
		String datasetsStaticMainDir = ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderStaticRootDirectory.DATASETS_MAIN_DIRECTORY;
		datasetsStaticMainDir = staticRootName + datasetsStaticMainDir; 
		createDirectory(datasetsStaticMainDir +ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetsDirectory.SYNTHETIC_DATA_ROOT_FOLDER_NAME);
		
		String latestResultsDirectoryName=ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderRootDirectory.LATEST_RESULTS_DIRECTORY;
		
		createSubDirectoriesForLatestResults(rootName+latestResultsDirectoryName);
		
		
	}
	
	public static void initializeNecessaryFiles()
	{
		String pathOfTheMatlabFiguresTexResultsFolder;		
		
		pathOfTheMatlabFiguresTexResultsFolder = ConstantVariable.DefaultDirectoryNamesConstants.ROOT_DIRECTORY+
		ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderRootDirectory.LATEST_RESULTS_DIRECTORY+
		ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderLatestResultsDirectory.GENERAL_RESULTS_DIRECTORY;
		
		String pathOfTheMatlabFiguresTexResultsFile = pathOfTheMatlabFiguresTexResultsFolder + ConstantVariable.DefaultFileNamesConstants.DefaultAllInOneResultsFiles.MATLAB_FIGURES_TEX_RSLTS_ALL_IN_ONE_FILENAME;
		
		String pathOfTheMatlabFiguresTexResultsFileBackup = pathOfTheMatlabFiguresTexResultsFolder + WorkerUtilityClass.getDateTimeForFileNames()
		+ ConstantVariable.Format_ConstantVariables.DASH_CHAR +ConstantVariable.DefaultFileNamesConstants.DefaultAllInOneResultsFiles.MATLAB_FIGURES_TEX_RSLTS_ALL_IN_ONE_FILENAME;
		
		if(new File(pathOfTheMatlabFiguresTexResultsFile).exists())
		{			
			Utility.FileUtilityClass.copyFile(pathOfTheMatlabFiguresTexResultsFile, pathOfTheMatlabFiguresTexResultsFileBackup, true, false);
			Utility.FileUtilityClass.deleteFile(pathOfTheMatlabFiguresTexResultsFile);
		}
		
		/*Necessary ones*/		
		
		pathOfTheMatlabFiguresTexResultsFile = pathOfTheMatlabFiguresTexResultsFolder + ConstantVariable.DefaultFileNamesConstants.DefaultAllInOneResultsFiles.MATLAB_FIGURES_TEX_IMPORTANT_RSLTS_ALL_IN_ONE_FILENAME;
		
		pathOfTheMatlabFiguresTexResultsFileBackup = pathOfTheMatlabFiguresTexResultsFolder + WorkerUtilityClass.getDateTimeForFileNames()
		+ ConstantVariable.Format_ConstantVariables.DASH_CHAR +ConstantVariable.DefaultFileNamesConstants.DefaultAllInOneResultsFiles.MATLAB_FIGURES_TEX_IMPORTANT_RSLTS_ALL_IN_ONE_FILENAME;
		
		if(new File(pathOfTheMatlabFiguresTexResultsFile).exists())
		{			
			Utility.FileUtilityClass.copyFile(pathOfTheMatlabFiguresTexResultsFile, pathOfTheMatlabFiguresTexResultsFileBackup, true, false);
			Utility.FileUtilityClass.deleteFile(pathOfTheMatlabFiguresTexResultsFile);
		}
		
		outForLogFile = createLogFile();
	}
	
	public static void createSubDirectoriesForLatestResults(String fullPathOfTheParent) 
	{		
		createDirectory(fullPathOfTheParent+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderLatestResultsDirectory.SYNTETIC_DATASETS_DEFINITIONS_DIRECTORY);
		createDirectory(fullPathOfTheParent+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderLatestResultsDirectory.SYNTETIC_DATASETS_RESULTS_DIRECTORY);
		createDirectory(fullPathOfTheParent+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderLatestResultsDirectory.PREDIFINED_DATASETS_RESULTS_DIRECTORY);
		createDirectory(fullPathOfTheParent+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderLatestResultsDirectory.GENERAL_RESULTS_DIRECTORY);
		
		createSubDirectoriesForSynteticDatasetsResultsDirectory(fullPathOfTheParent+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderLatestResultsDirectory.SYNTETIC_DATASETS_RESULTS_DIRECTORY);
	}
	
	public static void createSubDirectoriesForSynteticDatasetsResultsDirectory(String fullPathForTheDataset) 
	{
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderSynteticDatasetsResultsDirectory.SYNTETIC_DATASETS_GRAPHS_TOGETHER_DIRECTORY);		
		createSubDirectoriesForSynteticDatasetsGraphsTogetherDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderSynteticDatasetsResultsDirectory.SYNTETIC_DATASETS_GRAPHS_TOGETHER_DIRECTORY);
	}
	
	public static void createSubDirectoriesForSynteticDatasetsGraphsTogetherDirectory(String fullPathOfTheParent)
	{
		createGenericSubDirectoriesForGenericGraphProperty(fullPathOfTheParent);
	}
	
	public static void createSubDirectoriesForAStaticDataset(String fullPathForTheDataset) 
	{	
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderStaticDatasetDirectory.RAW_DATA_FOLDER_NAME);
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderStaticDatasetDirectory.BACKUP_RELATED_TO_DATASET_FOLDER_NAME);
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderStaticDatasetDirectory.INTEGRITY_RELATED_TO_DATASET_FOLDER_NAME);	
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderStaticDatasetDirectory.FEATURE_SELECTION_RELATED_TO_DATASET_FOLDER_NAME);		
	}
	
	public static void createSubDirectoriesForADataset(String fullPathForTheDataset) 
	{
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetDirectory.GRAPH_PROPERTIES_FOLDER_NAME);
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetDirectory.WEKA_RELATED_FOLDER_NAME);
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetDirectory.CORRELATIONS_RELATED_FOLDER_NAME);		
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetDirectory.CONTENT_RELATED_TO_DATASET_FOLDER_NAME);
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetDirectory.RAW_RESULTS_RELATED_TO_DATASET_FOLDER_NAME);
		
		createSubDirectoriesForWekaRelated(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetDirectory.WEKA_RELATED_FOLDER_NAME);
		createSubDirectoriesForGraphProperties(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetDirectory.GRAPH_PROPERTIES_FOLDER_NAME);
		createSubDirectoriesForContentRelated(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetDirectory.CONTENT_RELATED_TO_DATASET_FOLDER_NAME);
	}
	
	public static void createSubDirectoriesForWekaRelated(String fullPathForTheDataset) 
	{
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderWekaRelatedDirectory.DSV_FORMAT_DATA_FOLDER_NAME);	
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderWekaRelatedDirectory.ARFF_FORMAT_DATA_FOLDER_NAME);		
	}
	
	public static void createSubDirectoriesForGraphProperties(String fullPathForTheDataset) 
	{
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.DEGREE_RELATED_DATA_FOLDER_NAME);
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.CLUSTERING_COEFFICIENT_RELATED_DATA_FOLDER_NAME);
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.HOMOPHILY_RELATED_DATA_FOLDER_NAME);
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.RICHCLUB_COEFFICIENT_RELATED_DATA_FOLDER_NAME);
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.LOCAL_ALPHA_RELATED_DATA_FOLDER_NAME);
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.ACCURACY_RELATED_DATA_FOLDER_NAME);
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.SUMMARY_RELATED_DATA_FOLDER_NAME);
		
		
		createSubDirectoriesForDegreeRelated(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.DEGREE_RELATED_DATA_FOLDER_NAME);				
		createSubDirectoriesForClusteringCoefficientRelated(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.CLUSTERING_COEFFICIENT_RELATED_DATA_FOLDER_NAME);
		createSubDirectoriesForHomophilyRelated(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.HOMOPHILY_RELATED_DATA_FOLDER_NAME);
		createSubDirectoriesForRichClubCoefficientRelated(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.RICHCLUB_COEFFICIENT_RELATED_DATA_FOLDER_NAME);
		createSubDirectoriesForLocalAlphaRelated(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.LOCAL_ALPHA_RELATED_DATA_FOLDER_NAME);
		createSubDirectoriesForAccuracyRelated(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.ACCURACY_RELATED_DATA_FOLDER_NAME);
	}
	
	public static void createSubDirectoriesForContentRelated(String fullPathForTheDataset) 
	{
		createGenericSubDirectoriesForGenericGraphProperty(fullPathForTheDataset);
	}
	
	public static void createSubDirectoriesForDegreeRelated(String fullPathForTheDataset) 
	{
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDegreeRelatedDirectory.DEGREE_DISTRIBUTION_DATA_FOLDER_NAME);	
		
		createSubDirectoriesForDegreeDistribution(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDegreeRelatedDirectory.DEGREE_DISTRIBUTION_DATA_FOLDER_NAME);				
	}
	
	public static void createSubDirectoriesForDegreeDistribution(String fullPathForTheDataset) 
	{
		createGenericSubDirectoriesForGenericGraphProperty(fullPathForTheDataset);				
	}
	
	public static void createSubDirectoriesForClusteringCoefficientRelated(String fullPathForTheDataset) 
	{
		createGenericSubDirectoriesForGenericGraphProperty(fullPathForTheDataset);				
	}
	
	public static void createSubDirectoriesForHomophilyRelated(String fullPathForTheDataset) 
	{
		createGenericSubDirectoriesForGenericGraphProperty(fullPathForTheDataset);				
	}
	
	public static void createSubDirectoriesForRichClubCoefficientRelated(String fullPathForTheDataset) 
	{
		createGenericSubDirectoriesForGenericGraphProperty(fullPathForTheDataset);				
	}
	
	public static void createSubDirectoriesForLocalAlphaRelated(String fullPathForTheDataset)
	{
		createGenericSubDirectoriesForGenericGraphProperty(fullPathForTheDataset);		
	}
	
	public static void createSubDirectoriesForAccuracyRelated(String fullPathForTheDataset)
	{
		createGenericSubDirectoriesForGenericGraphProperty(fullPathForTheDataset);		
	}
	
	public static void createGenericSubDirectoriesForGenericGraphProperty(String fullPathForTheDataset)
	{
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGenericGraphPropertyDirectory.RAW_DATA_FOLDER_NAME);
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGenericGraphPropertyDirectory.MATLAB_CODE_FOLDER_NAME);
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGenericGraphPropertyDirectory.MATLAB_FIGURE_DATA_FOLDER_NAME);	
		
		createSubDirectoriesUnderMatlabFigure(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGenericGraphPropertyDirectory.MATLAB_FIGURE_DATA_FOLDER_NAME);
	}
	
	public static void createSubDirectoriesUnderMatlabFigure(String fullPathForTheDataset) 
	{
		createDirectory(fullPathForTheDataset+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderMatlabFigure.LATEX_FILES_OF_THE_FIGURES);				
	}	
	
	public static File createFile(String fullPathForTheDataset, String filename)
	{
		File f;
		//System.out.println("CreateFileAt : "+fullPathForTheDataset+filename);
		f=new File(fullPathForTheDataset+filename);
		
		if(!f.exists()){
			try {
				f.createNewFile();
				if(filename!=DefaultDirectoryNamesConstants.OtherFileNames.GENERAL_LOG_FILENAME)
					DirectoryStructureAndSettingsClass.addToLog("New file " + filename +" is created under "+fullPathForTheDataset);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}			
		}
		return f;
	}
	
	 public static BufferedWriter getFileOutForTheFile(String directoryName, String fileName, boolean append)
	 {
		 try {

			 File descFile=DirectoryStructureAndSettingsClass.createFile(directoryName, fileName);
			 FileWriter fstream;
			 fstream = new FileWriter(descFile, append);
			 BufferedWriter out = new BufferedWriter(fstream);
			 return out;
		 } catch (IOException e) {
			 // TODO Auto-generated catch block
			 e.printStackTrace();
		 }
		 return null;
	 }
	 
	 public static BufferedReader getFileInForTheFile(String directoryName, String fileName)
	 {
		 try {

			 File descFile=DirectoryStructureAndSettingsClass.createFile(directoryName, fileName);
			 FileReader fstream;
			 fstream = new 	FileReader(descFile);
			 BufferedReader in = new BufferedReader(fstream);
			 return in;
		 } catch (IOException e) {
			 // TODO Auto-generated catch block
			 e.printStackTrace();
		 }
		 return null;
	 }
	
	public static BufferedWriter createLogFile()
	{
		String path= ConstantVariable.DefaultDirectoryNamesConstants.ROOT_DIRECTORY
			+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderRootDirectory.LOG_DIRECTORY;
		
		String fileName = DefaultDirectoryNamesConstants.OtherFileNames.GENERAL_LOG_FILENAME;
		
		try {

			 File descFile=DirectoryStructureAndSettingsClass.createFile(path, fileName);
			 FileWriter fstream;
			 fstream = new FileWriter(descFile, true);
			 BufferedWriter out = new BufferedWriter(fstream);
			 return out;
		 } catch (IOException e) {
			 // TODO Auto-generated catch block
			 e.printStackTrace();
		 }
		 return null;
	}
	
	public static void addToLog(String stringToBeAppendedToTheLogFile)
	{
		try {
			outForLogFile.write((stringToBeAppendedToTheLogFile));
			outForLogFile.write("\n");
			outForLogFile.flush();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
    public static BufferedWriter createTheFileSpecified(String path, String fileName, boolean appendMode)
    {
    	try {
    		
    		File descFile=DirectoryStructureAndSettingsClass.createFile(path, fileName);
    		FileWriter fstream;
    		fstream = new FileWriter(descFile, appendMode);
    		BufferedWriter out = new BufferedWriter(fstream);
    		return out;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;    	
    }
}
